package com.WJY.controller;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
    private Integer code;
    private Object data;
    private String msg;


    //创建两种静态方法
    public static R success(Integer code, Object data) {
        return new R(code, data);
    }

    public static R success(Integer code, String msg) {
        return new R(code, msg);
    }

    public static R failure(Integer code, String msg) {
        return new R(code, msg);
    }


    //下面两个构造函数是为了上面的两种静态方法而存在
    public R(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public R(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

}
